<template>
  <div class="app-container" style="width: 100%; height: 100%">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="90px"
    >
      <el-form-item label="航标类型" prop="zdXlh">
        <el-input
          v-model="queryParams.zdXlh"
          placeholder="请输入航标类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="周期" prop="period">
        <el-input
          v-model="queryParams.period"
          placeholder="请输入周期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <div style="width: 100%">
      <div
        style="
          width: 100%;
          height: 124px;
          display: flex;
          justify-content: space-between;
        "
      >
        <div class="boxM" style="width: calc((100% / 3) - 10px); height: 100%">
          <div
            style="
              width: calc(100% - 15%);
              height: 100%;
              display: flex;
              flex-direction: column;
              justify-content: space-evenly;
            "
          >
            <div>航标航标</div>
            <div style="font-size: 32px; font-weight: bold">0000/0000</div>
          </div>
          <div style="width: 15%; height: 100%"><Echartbar></Echartbar></div>
        </div>
        <div class="boxM" style="width: calc((100% / 3) - 10px); height: 100%">
          <div
            style="
              width: calc(100% - 15%);
              height: 100%;
              display: flex;
              flex-direction: column;
              justify-content: space-evenly;
            "
          >
            <div>航标航标</div>
            <div style="font-size: 32px; font-weight: bold">0000/0000</div>
          </div>
          <div style="width: 15%; height: 100%"><Echartbar></Echartbar></div>
        </div>
        <div class="boxM" style="width: calc((100% / 3) - 10px); height: 100%">
          <div
            style="
              width: calc(100% - 15%);
              height: 100%;
              display: flex;
              flex-direction: column;
              justify-content: space-evenly;
            "
          >
            <div>航标航标</div>
            <div style="font-size: 32px; font-weight: bold">0000/0000</div>
          </div>
          <div style="width: 15%; height: 100%"><Echartbar></Echartbar></div>
        </div>
      </div>
      <div
        style="
          width: 100%;
          height: 290px;
          margin-top: 10px;
          background: rgba(0, 0, 0, 0.02);
        "
        ref="echBar"
      ></div>
    </div>
    <div style="width: 100%; height: calc(100% - 487px); margin-top: 10px">
      <div>
        <el-button type="danger" plain icon="el-icon-delete">删除</el-button
        ><el-button type="primary" icon="el-icon-tickets">导出</el-button>
      </div>
      <el-table
        :data="tableData"
        style="width: 100%; height: calc(100% - 65px)"
      >
        <el-table-column prop="date" label="日期" width="180">
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="180">
        </el-table-column>
        <el-table-column prop="address" label="地址"> </el-table-column>
      </el-table>
      <el-pagination layout="prev, pager, next" :total="50"> </el-pagination>
    </div>
  </div>
</template>
<script>
import Echartbar from "./EchartMod/Echartbar.vue";
import * as echarts from "echarts";
export default {
  components: { Echartbar },
  //变量
  data() {
    return { queryParams: {}, tableData: [] };
  },
  //初始
  mounted() {
    this.$nextTick(() => {
      this.Echarts = echarts.init(this.$refs.echBar, "macarons");
      this.getEchart();
      window.addEventListener("resize", () => {
        //重置容器高宽
        echarts.resize();
      });
    });
  },
  //事件
  methods: {
    handleQuery() {},
    resetQuery() {},
    getEchart() {
      const range = 75;
      var option = {
        tooltip: {}, //详情提示
        legend: {
          show: false,
        },
        grid: {
          // top: 110,
          top: 40,
        right: 20,
        left: '5%',
        bottom: 30,
        },
        xAxis: {
          //配置x轴，x轴和y轴互换
          type: "value", //值轴
        },
        yAxis: {
          //配置y轴
          type: "category", //类目轴
          data: ["雪碧", "可乐", "冰红茶", "绿茶", "茶π", "红牛"],
        },
        series: [
          //配置数据系列，一个图表可以配置多个数据系列
          {
            name: "",
            type: "bar", //数据系统的类型，即图表的类型。bar代表柱状状图
            itemStyle: {
              color: "#478BFE",
            },
            data: [10, 2, 3, 4, 5, 6],
          },
        ],
      };
      this.Echarts.setOption(option);
      setTimeout(() => {
        this.Echarts.resize();
      }, 100);
    },
  },
  //销毁
  beforeDestroy() {
    if (this.Echarts) {
      // 清除实例，释放资源
      this.Echarts.dispose();
      // 将实例设为null，避免潜在的内存泄漏
      this.Echarts = null;
    }
  },
};
</script>
<style scoped>
.boxM {
  padding: 10px;
  background: rgba(0, 0, 0, 0.02);
  display: flex;
  justify-content: space-between;
}
</style>
